#import "XMShopViewController.h"
#import "XMShopViewCell.h"

@interface XMShopViewController() <UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) UITableView *tableView;

@end

@implementation XMShopViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    self.view.backgroundColor = kColorHEX(0xF0F0F0);
    [self hideNavigationBar:NO animated:YES];

    _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    [_tableView registerClass:[XMShopViewCell class] forCellReuseIdentifier:@"ProductCell"];
//    self.tableView.backgroundColor = kColorHEX(0xF0F0F0);
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:_tableView];
    [self orderList];
}
-(void)orderList
{
  
    NSMutableDictionary * mutableDict = @{@"orderId":@"",@"pageNo":@"1",@"pageSize":@"10"}.mutableCopy;
    [[XMNetwork shareInstance]getDataWithPath:[NSString stringWithFormat:@"%@%@",HttpInterface,orderAddress] parameters:nil needToken:NO headers:nil success:^(id  _Nonnull responseObject) {
          NSDictionary * resultDic = responseObject;
          NSArray * data = [resultDic objectForKey:@"data"];
          NSLog(@"%@",data);
         } failure:^(NSError * _Nonnull error) {
             if(error.code == 401){
                 [MBProgressHUD showError:error.localizedDescription];
                 
            }
       }];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 4;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return  150;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    XMShopViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ProductCell" forIndexPath:indexPath];

    UIImage *image = [UIImage imageNamed:@"product_image"]; // 需准备对应图片
    NSString *name = @"摩托估值选车指导交流这是产品名称这是产品名称";
    NSString *price = @"¥99.00";
    [cell configureWithImage:image name:name price:price];
    return cell;
}

@end
